home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / keycomm.arc / KEYCOMM.ASM next >
Assembly Source File  |  1988-09-19  |  5KB  |  133 lines

  1. ;   Source code for KEYCOMM.ASM
  2.  
  3.  
  4.  
  5. ;  This is a modified version of a very simple comm program from
  6. ; NRI. The original was made up of a bunch of subroutines that were called
  7. ; one after another. I just converted it so that there are no call instructions
  8. ; or returns, except for the interupt service routine.
  9. ; Trilobyte  user #151
  10. ; Electric Dreams BBS
  11. ; 1-414-654-9159
  12. ;      or
  13. ;Duane Saaski
  14. ;Exec pc
  15.  
  16.  
  17.  
  18.  
  19.                 mov ah,09h
  20.                 mov dx,offset hello
  21.                 int 21h                 ;print hello message
  22.                 jmp start
  23. old_seg         dw 00
  24. old_off         dw 00
  25. buf_ptr         dw 00
  26. dis_ptr         dw 00
  27. buf_end         dw 0ffh
  28. start:          mov ah,35h
  29.                 mov al,0ch
  30.                 int 21h                 ;get com1 interupt vector
  31.                 mov old_seg,es
  32.                 mov old_off,bx
  33.                 mov dx,offset com
  34.                 mov ah,25h
  35.                 mov al,0ch
  36.                 int 21h                 ;store new com1 interupt vector
  37.                 mov dx,03f9h
  38.                 mov al,1
  39.                 out dx,al               ;select type of com1 interupt
  40.                 in al,21h
  41.                 and al,not 10h
  42.                 out 21h,al              ;program interupt chip
  43.                 push ds                 ;save old data segment
  44.                 mov ds,cs
  45.                 mov al,0bh
  46.                 mov dx,03fc        ;modem control
  47.                 out dx,al
  48.                 mov al,80h
  49.                 mov dx,03fbh
  50.                 out dx,al          ;divisor access
  51.                 mov al,60h
  52.                 mov dx,03f8h
  53.                 out dx,al          ;set baud rate
  54.                 inc dx
  55.                 mov al,00
  56.                 out dx,al
  57.                 mov dx,03fbh
  58.                 mov al,3
  59.                 out dx,al           ;set line parameters
  60. display:        mov bx,dis_ptr
  61.                 cmp bx,buf_ptr          ;jump to key polling if
  62.                 jz key                  ;there is no new char in buffer
  63.                 mov al,[buffer+bx]      ;get character from buffer
  64.                 inc bx                  ;increment dis_ptr in bx
  65.                 cmp bx,buf_end          ;see if at end of buffer
  66.                 jne roomy2
  67.                 xor bx,bx               ;set dis_ptr to 0
  68. roomy2:         mov dis_ptr,bx
  69.                 mov ah,0eh
  70.                 mov bh,0
  71.                 int 10h                 ;output teletype character
  72. key:            mov dx,03fdh
  73.                 in al,dx                ;check if transmit hold reg. is empty
  74.                 test al,20h
  75.                 jz display              ;if full goto display
  76.                 mov ah,6
  77.                 mov dl,0ffh
  78.                 int 21h                 ;keyboard input
  79.                 jz display              ;if no character,leave
  80.                 cmp al,01bh             ;check for escape
  81.                 jz exit
  82.                 mov dx,03f8h
  83.                 out dx,al               ;output to com1
  84.                 jmp display
  85. com:            sti                     ;start of interupt service
  86.                 push ax,bx,dx,ds
  87.                 push cs
  88.                 pop ds
  89.                 mov dx,03f8h            ;get character on-line
  90.                 in al,dx
  91.                 cli
  92.                 mov bx,buf_ptr          ;get buffer pointer
  93.                 mov [buffer+bx],al      ;stick character in buffer
  94.                 inc bx                  ;increment buffer pointer
  95.                 cmp bx,buf_end          ;see if at end of buffer
  96.                 jne roomy1              ;if not goto roomy1
  97.                 xor bx,bx               ;if so, set buf_ptr to zero
  98. roomy1:         mov buf_ptr,bx          ;save buf_ptr
  99.                 sti                     ;turn interupts on
  100.                 mov al,20h              ;end of interupt
  101.                 out 20h,al              ;instruction
  102.                 pop ds,dx,bx,ax
  103.                 iret
  104. exit:           pop ds                  ;get ds back
  105.                 mov ah,9
  106.                 mov dx,offset bye_msg
  107.                 int 21h                 ;print goodbye message
  108.                 mov al,0
  109.                 mov dx,03f9h    ;turn off 8250 interupts
  110.                 out dx,al
  111.                 in al,21h       ;turn off com1 in interupt chip
  112.                 or al,10h
  113.                 out 21h,al
  114.                 push ds
  115.                 mov dx,old_off  ;   -------
  116.                 mov ds,old_seg  ;      ^
  117.                 mov ah,25h      ;      |
  118.                 mov al,0ch      ;      |
  119.                 int 21h         ;replace interupt vector
  120.                 pop ds
  121.                 mov ah,4ch
  122.                 mov al,0
  123.                 int 21h         ;program end
  124. bye_msg:        db 'Program terminated.',13,10,'$'
  125. hello:          db 'Com1--1200-8-N-1     hit esc key to exit.',13,10,'$'
  126. buffer          db 256 dup(0)
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.